<%-- 
    Document   : CMS_paymentMethod
    Created on : Nov 22, 2013, 3:21:56 PM
    Author     : BibooChung
--%>

<!DOCTYPE html>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import = "java.util.*" import="cart.hibernate.paymentMethod.*" import="cart.*,java.net.*,java.text.*" %>
<jsp:useBean id = "manager" scope= "request" class = "cart.hibernate.paymentMethod.ManagePaymentMethod" />

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script type="text/javascript" src="js/bootstrap.min.js"></script>
        <script type="text/javascript" src="js/CMS.js"></script>
        <link type="text/css" href="css/CMS.css" rel="stylesheet" />
        <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
        <link href="css/font-awesome.min.css" rel="stylesheet" media="screen">
        <link href="css/bootflat.css" rel="stylesheet" media="screen">
        <link href="css/bootflat-extensions.css" rel="stylesheet" media="screen">
        <link href="css/bootflat-square.css" rel="stylesheet" media="screen">
    </head>
    <body>
        <jsp:include page="CMS_menu.html" />
        <h1>Manage Payment Method</h1>

        <!-- Table with integrated management -->
        <table style="margin-bottom:20px;" class="table table-striped">
            <thead>
                <tr>
                    <th>Payment Method ID</th>
                    <th>Payment Method</th>
                    <th>Delete?</th>
                </tr>
            </thead>
            <tbody>
                <%
                    List paymentMethodList = manager.getAllPaymentMethod();
                    Iterator iter = paymentMethodList.iterator();

                    while (iter.hasNext())
                    {

                        PaymentMethod paymentMethod = (PaymentMethod) iter.next();
                %>
                        <tr>
                            <form action="ManagePaymentMethodServlet" method="post">
                                <input type="hidden" name="paymentMethodId" value="<%= paymentMethod.getPaymentMethodId() %>">
                                <td>
                                    <%= paymentMethod.getPaymentMethodId() %>
                                </td>
                                <td>
                                    <input type="text" name="paymentMethod" value="<%= paymentMethod.getPaymentMethod() %>" class="form-control" />
                                    <input type="submit" name="submit" value="update" class="btn btn-primary">
                                </td>
                                <td>
                                    <input type="submit" name="submit" value="delete" class="btn btn-danger">
                                </td>
                            </form>
                        </tr>
                <%        
                    }
                %>
            </tbody>
        </table>
        <table>
            <tr>
                <form action="ManagePaymentMethodServlet" method="post">
                    <td>Enter new paymentMethod : </td>
                    <td><input type="text" name="paymentMethod" id="paymentMethod" placeholder="Payment Method" class="form-control" /></td>
                    <td><input type="submit" name="submit" value="add" class="btn btn-primary"></td>
                </form>
            </tr>
        </table>

        <!-- Table with delete and update -->
        <table style="margin-bottom:20px;" class="table table-striped">
            <thead>
                <tr>
                    <th>Payment Method ID</th>
                    <th>Payment Method</th>
                    <th>Delete?</th>
                </tr>
            </thead>
            <tbody>
            <%
                paymentMethodList = manager.getAllPaymentMethod();
                iter = paymentMethodList.iterator();

                while (iter.hasNext())
                {

                    PaymentMethod paymentMethod = (PaymentMethod) iter.next();
            %>
                    <tr>
                        <td>
                            <%= paymentMethod.getPaymentMethodId() %>
                        </td>
                        <td>
                            <form action="UpdatePaymentMethodServlet" method="post">
                                <input type="hidden" name="id" value="<%= paymentMethod.getPaymentMethodId() %>">
                                <input type="text" name="paymentMethod" value="<%= paymentMethod.getPaymentMethod() %>" class="form-control" />
                                <input type="submit" value="update" class="btn btn-primary">
                            </form>
                        </td>
                        <td>
                            <form action="DeletePaymentMethodServlet" method="post">
                                <input type="hidden" name="id" value="<%= paymentMethod.getPaymentMethodId() %>">
                                <input type="submit" value="delete" class="btn btn-danger">
                            </form>
                        </td>
                    </tr>

            <%        
                }
            %>
            </tbody>
        </table>


        <!-- Table with delete -->
        <table style="margin-bottom:20px;" class="table table-striped">
            <thead>
                <tr>
                    <th>Payment Method ID</th>
                    <th>Payment Method</th>
                    <th>Delete?</th>
                </tr>
            </thead>
            <tbody>
            <%
                paymentMethodList = manager.getAllPaymentMethod();
                iter = paymentMethodList.iterator();

                while (iter.hasNext())
                {

                    PaymentMethod paymentMethod = (PaymentMethod) iter.next();
            %>
                    <tr>
                        <form action="DeletePaymentMethodServlet" method="post">
                            <td><%= paymentMethod.getPaymentMethodId() %></td>
                            <td><%= paymentMethod.getPaymentMethod() %></td>
                            <td>
                            <input type="hidden" name="id" value="<%= paymentMethod.getPaymentMethodId() %>">
                            <input type="submit" value="delete" class="btn btn-danger">
                            </td>
                        </form>
                    </tr>

            <%        
                }
            %>
            </tbody>
        </table>


        <!-- Table show all data -->
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>Payment Method ID</th>
                    <th>Payment Method</th>
                </tr>
            </thead>
            <tbody>
            <%
                paymentMethodList = manager.getAllPaymentMethod();
                iter = paymentMethodList.iterator();

                while (iter.hasNext())
                {

                    PaymentMethod paymentMethod = (PaymentMethod) iter.next();
            %>
                    <tr>
                        <td><%= paymentMethod.getPaymentMethodId() %></td>
                        <td><%= paymentMethod.getPaymentMethod() %></td>
                    </tr>

            <%        
                }
            %>
            </tbody>
        </table>

        <table>
            <tr>
                <form id="form" method="post" action="addPaymentMethodServlet">
                    <td>Enter the new payment method name</td>
                    <td><input type="text" name="paymentMethod" id="paymentMethod" placeholder="Payment Method" class="form-control" /></td>
                    <td><button type="submit" class="btn btn-primary">Register</button></td>
                </form>
            </tr>
        </table>
    </body>
</html>
